<template>
	<view class="bg-white h_100">
		<view v-if="!info" class="p-2" style="margin:auto;"><u-empty mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" text="暂无详情内容"></u-empty></view>
		<view v-else>
			<view class="bg-white p-2">
				<view class="my-1 h3 font-weight-bold">{{ info.title }}</view>
				<view class="font_24 c_9">
					<view v-if="info.add_time">时间：{{ info.add_time }}</view>
					<view v-if="info.address">地点：{{ info.address }}</view>
					<view v-if="info.capacity">装机容量：{{ info.capacity }}</view>
				</view>
				<image v-if="info.thumb" class="forum_img mt-2" :src="info.thumb" mode="aspectFill"></image>
			</view>
			<view class="bg-white p-2"><rich-text class="view" :nodes="info.introduce | formatRichText"></rich-text></view>
			<view class="bg-white p-2"><rich-text class="view" :nodes="info.content | formatRichText"></rich-text></view>
		</view>
	</view>
</template>

<script>
import { getProjectDetail } from '@/api/home/company.js';
import util from '@/common/js/util.js';
export default {
	data() {
		return {
			info: {}
		};
	},
	filters: {
		formatRichText(html) {
			return util.formatRichText(html);
		}
	},
	onLoad(option) {
		// console.log(option);
		this.getInfo(option.id);
		// 分享
		wx.showShareMenu({
			withShareTicket: true,
			menus: ['shareAppMessage', 'shareTimeline']
		});
	},
	methods: {
		getInfo(val) {
			let msg = {
				id: val,
				uid: uni.getStorageSync('userInfo').userId || ''
			};
			getProjectDetail(msg)
				.then(res => {
					// console.log(res);
					if (res.code == 0) {
						this.info = res.data;
					} else {
						uni.$u.toast(res.msg);
					}
				})
				.catch(err => {
					console.log('获取案例详情失败', err);
				});
		}
	}
};
</script>

<style lang="scss" scoped>
.forum_img {
	width: 100%;
	height: 395rpx;
	border-radius: 15rpx 15rpx 0 0;
}
.forum_cont {
	border-radius: 0 0 15rpx 15rpx;
}
</style>
